package com.migo.api;

import com.migo.annotation.IgnoreAuth;
import com.migo.entity.PvMgFirmwareLogEntity;
import com.migo.service.PvMgFirmwareLogService;
import com.migo.thread.AfterSaleUserAddressThread;
import com.migo.thread.PvMgFirmwareLogThread;
import com.migo.utils.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;


/**
 * PVMG10记录固件升级日志 - 异步
 * 
 * @author powervision
 * @email zhenrong.xu@powervision.me
 * @date 2021-07-08 12:07:07
 */
@RestController
@RequestMapping("/api/pvmgfirmwarelog")
public class ApiPvMgFirmwareLogController {
	@Autowired
	private PvMgFirmwareLogService pvMgFirmwareLogService;
	

	
	/**
	 * 记录固件升级日志 - 异步
	 */
	@IgnoreAuth
	@RequestMapping(value = "saveMgFirmwareTimes", produces = "application/json;charset=utf-8;")
	public R saveMgFirmwareTimes(@RequestBody PvMgFirmwareLogEntity pvMgFirmwareLog, HttpServletRequest request){
		String ip = IPUtils.getIpAddr(request);
		pvMgFirmwareLog.setIpAddress(ip);
		ExecutorService threadPool = ThreadPoolUtils.getThreadPool();
		threadPool.execute(new PvMgFirmwareLogThread(pvMgFirmwareLogService, pvMgFirmwareLog));
		
		return R.ok();
	}
	

	
}
